/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: rtos its enhance feature functions
 * Author: huyizhou
 * Create: 2023-09-14
 */

#ifdef CONFIG_RTOS_HAL_UGIC_IMIT
static int its_irq_set_irqchip_state_enhance(struct irq_data *d,
				     enum irqchip_irq_state which,
				     bool state)
{
	struct its_device *its_dev = irq_data_get_irq_chip_data(d);
	u32 event = its_get_event_id(d);

	switch (which) {
	case IRQCHIP_STATE_MASKED:
		if (state)
			its_mask_irq(d);
		else
			its_unmask_irq(d);
		break;
	case IRQCHIP_STATE_PENDING:
		if (irqd_is_forwarded_to_vcpu(d)) {
			if (state)
				its_send_vint(its_dev, event);
			else
				its_send_vclear(its_dev, event);
		} else {
			if (state)
				its_send_int(its_dev, event);
			else
				its_send_clear(its_dev, event);
		}
		break;
	default:
		return -EINVAL;
	}
	return 0;
}
#else
static int its_irq_set_irqchip_state_enhance(struct irq_data *d,
				     enum irqchip_irq_state which,
				     bool state)
{
	return 0;
}
#endif
